<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/common2 :: common_head(~{::title},~{},~{})">
    <title>分析版本配置</title>
</head>

<body>
<script type="text/javascript">

    var initNeededParam = {
        INIT_PARAM_ISNEED: "1",
        INIT_PARAM_ISUNNEED: "0"
    };

    Ext.define('Override.form.field.VTypes', {
        override: 'Ext.form.field.VTypes',
        versionCheck: function (value) {
            return this.versionRe.test(value);
        },
        versionRe: /^(\d{1,3}\.){1}\d{1,3}$/,
        versionCheckText: '版本号格式为{num}.{num},如1.0'
    });

    Ext.onReady(function () {
        /**分析映射数据以及窗口和表单信息***/
        var modelMapped = Ext.create("Ext.data.Model", {
            fields: [
                {
                    type: 'string',
                    name: 'modifiedTime'
                },
                {
                    type: 'string',
                    name: 'mappingId'
                }, {
                    type: 'string',
                    name: 'analyseTypeOri'
                }, {
                    type: 'string',
                    name: 'analyseTypeMapped'
                }, {
                    type: 'string',
                    name: 'remark'
                }
            ]
        });

        var storeMapped = Ext.create('Ext.data.Store', {
            model: modelMapped,
            autoLoad: true,
            start: 0,
            //20
            limit: 10,
            //20
            pageSize: 10,
            proxy: {
                type: 'ajax',
                api: {
                    read: GS.global.ctxPath + '/analyseMapped/getAnalyseMapped'
                },
                actionMethods: {
                    read: 'POST' // Store设置请求的方法，与Ajax请求有区别
                },
                /**设置读取方式*/
                reader: {
                    type: 'json',
                    rootProperty: 'data.records',
                    totalProperty: 'data.total'
                }
            }
        });

        /**分页*/
        var pageComboMapped = Ext.create('Ext.form.ComboBox', {
            name: 'pagesize',
            hiddenName: 'pagesize',
            store: new Ext.data.ArrayStore({
                fields: ['text', 'value'],
                data: [
                    ['10', 10]
                ]
            }),
            valueField: 'value',
            displayField: 'text',
            //20
            emptyText: 10,
            width: 50
        });

        //添加下拉显示条数菜单选中事件
        pageComboMapped.on("change", function (comboBox) {
            var pagingToolbar = Ext.getCmp('pagingbarMapped');
            pagingToolbar.pageSize = parseInt(comboBox.getValue());
            var itemsPerPageMapped = parseInt(comboBox.getValue());//更改全局变量itemsPerPage
            storeMapped.pageSize = itemsPerPageMapped;
            storeMapped.loadPage(1);
        });

        var gridMapped = Ext.create('Ext.grid.Panel', {
            tbar: [
                '->', {
                    text: '新增',
                    handler: function () {
                        doMappedAnalyseProfile();
                    }
                },
                {
                    text: '删除',
                    handler: function () {
                        deleteMappedRecordMapped();
                    }
                }
            ],
            dockedItems: [{
                id: 'pagingbarMapped',
                xtype: 'pagingtoolbar',
                store: storeMapped,
                dock: 'bottom',
                displayInfo: true,
                autoScroll: true,
                beforePageText: "第",// update
                afterPageText: "页  共 {0} 页",// update
                firstText: "第一页",
                prevText: "上一页",// update
                nextText: "下一页",
                lastText: "最后页",
                refreshText: "刷新",
                displayMsg: "显示 {0} - {1}条，共 {2} 条",// update
                emptyMsg: '没有数据',
                items: ['-', '每页显示', pageComboMapped, '条']//此处是将创建的combobox添加到工具栏中
            }],
            store: storeMapped,
            columns: [
                {
                    xtype: 'rownumberer',
                    header: '行号',
                    renderer: function (value, metadata, record, rowIndex) {
                        return (rowIndex + 1);
                    },
                    width: 60,
                    align: 'center'
                },
                {
                    text: '原始分析类型',
                    width: 240,
                    dataIndex: 'analyseTypeOri'
                },
                {
                    text: '映射后分析类型',
                    width: 210,
                    dataIndex: 'analyseTypeMapped'
                },
                {
                    text: '备注',
                    flex: 10,
                    dataIndex: 'remark'
                }
            ]
        });


        var formMapped = Ext.create('Ext.form.Panel', {
            border: false,
            layout: {type: 'auto', align: 'right'},
            buttonAlign: 'center',
            defaultType: 'textfield',
            items: [
                {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [{
                        xtype: 'textfield',
                        name: 'action',
                        hidden: true,
                        hideLabel: true
                    }, {
                        xtype: 'textfield',
                        name: 'mappingId',
                        hidden: true,
                        hideLabel: true
                    }, {
                        xtype: 'textfield',
                        name: 'modifiedTime',
                        hidden: true,
                        hideLabel: true
                    }
                    ]
                },
                {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: '原始分析类型',
                            name: 'analyseTypeOri',
                            flex: 5,
                            allowBlank: false,
                            margin: '5 5 5 5'
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: '映射后分析类型',
                            id: 'mapped_analyse_type',
                            name: 'analyseTypeMapped',
                            flex: 5,
                            allowBlank: false,
                            margin: '5 5 5 5',
                            readOnly: 'true'
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'textareafield',
                            fieldLabel: '备注',
                            name: 'remark',
                            flex: 5,
                            allowBlank: false,
                            margin: '5 5 5 5',
                            height: "80px",
                            maxLength: 50
                        }]
                }
            ]
        });

        var mappedSumWindow = Ext.create('Ext.Window', {
                title: '分析映射配置页',
                width: 700,
                height: 550,
                resizable: false,
                modal: true,
                //,gridMapped
                layout: 'auto',
                items: [formMapped, gridMapped],
                maximizable: true,
                minimizable: true,
                closeAction: 'hide'
            }
        );


        /***分析映射页面结束***/

        var model = Ext.create('Ext.data.Model', {
            fields: [
                {
                    type: 'string',
                    name: 'versionId'
                },
                {
                    type: 'string',
                    name: 'versionNo'
                },
                {
                    type: 'string',
                    name: 'analyseType'
                },
                {
                    type: 'string',
                    name: 'analyseName'
                },
                {
                    type: 'string',
                    name: 'analyseDes'
                },
                {
                    type: 'date',
                    name: 'publicTime'
                },
                {
                    type: 'string',
                    name: 'url'
                },
                {
                    type: 'string',
                    name: 'query_type'
                },
                {
                    type: 'string',
                    name: 'application_guid'
                },
                {
                    type: 'boolean',
                    name: 'needQsnd'
                },
                {
                    type: 'boolean',
                    name: 'needGdnd'
                },
                {
                    type: 'boolean',
                    name: 'needDlnd'
                },
                {
                    type: 'boolean',
                    name: 'needBuff'
                },
                {
                    type: 'boolean',
                    name: 'sffhtx'
                },
                {
                    type: 'string',
                    name: 'remark'
                }
            ]
        });


        var store = Ext.create('Ext.data.Store', {
            start: 0,
            limit: 10,
            pageSize: 10,
            model: model,
            autoLoad: true,
            proxy: {
                type: 'ajax',
                api: {
                    read: GS.global.ctxPath + '/analyse/getAnalyseVersions'
                },
                actionMethods: {
                    read: 'POST' // Store设置请求的方法，与Ajax请求有区别
                },
                /**设置读取方式*/
                reader: {
                    type: 'json',
                    rootProperty: 'data.records',
                    totalProperty: 'data.total'
                }
            },
            listeners: {
                'beforeload': function (store, op, options) {
                    var params = {
                        query_analyse_name: Ext.getCmp('query_analyse_name').getValue()
                    };
                    Ext.apply(store.proxy.extraParams, params);
                }
            }
        });


        /**分析类型数据**/
        var analysisTypeStore = Ext.create('Ext.data.Store', {
            autoLoad: true,
            fields: ['type', 'name'],
            proxy: {
                type: 'ajax',
                api: {
                    read: GS.global.ctxPath + '/enum/getAnalysisTypeValues'
                },
                actionMethods: {
                    read: 'POST', // Store设置请求的方法，与Ajax请求有区别
                },
                /**设置读取方式*/
                reader: {
                    type: 'json'
                }
            }
        });

        /**分页*/
        var pageCombo = Ext.create('Ext.form.ComboBox', {
            name: 'pagesize',
            hiddenName: 'pagesize',
            store: new Ext.data.ArrayStore({
                fields: ['text', 'value'],
                data: [
                    ['10', 10], ['20', 20], ['50', 50]
                ]
            }),
            valueField: 'value',
            displayField: 'text',
            emptyText: 10,
            width: 50
        });

        //添加下拉显示条数菜单选中事件
        pageCombo.on("change", function (comboBox) {
            var pagingToolbar = Ext.getCmp('pagingbar');
            pagingToolbar.pageSize = parseInt(comboBox.getValue());
            var itemsPerPage = parseInt(comboBox.getValue());//更改全局变量itemsPerPage
            store.pageSize = itemsPerPage;
            store.loadPage(1);
        });

        var grid = Ext.create('Ext.grid.Panel', {
            id: 'versionGrid',
            title: '配置分析版本页面',
            tbar: [{
                xtype: 'button',
                text: '新增',
                iconCls:'Add',
                handler: function () {
                    doAnalyseProfile('add');
                }
            },
                {
                    text: '编辑',
                    iconCls: 'Edit1',
                    handler: function () {
                        doAnalyseProfile('update');
                    }
                },
                {
                    text: '删除',
                    iconCls: 'Delete',
                    handler: function () {
                        deleteRecord();
                    }
                }, '->',
                {
                    xtype: 'textfield',
                    id: 'query_analyse_name',
                    name: 'query_analyse_name',
                    emptyText: '请输入分析名称...',
                }, {
                    xtype: 'button',
                    id: 'btnStuListQuery',
                    text: '查询',
                    iconCls: 'Preview',
                    handler: function () {
                        store.loadPage(1);
                    }
                }, {
                    xtype: 'button',
                    id: 'btnStuListReset',
                    iconCls: 'Arrowrefresh',
                    text: '刷新',
                    handler: function () {
                        Ext.getCmp('query_analyse_name').reset();
                        store.loadPage(1);
                    }
                }
            ],
            dockedItems: [{
                id: 'pagingbar',
                xtype: 'pagingtoolbar',
                store: store,
                dock: 'bottom',
                displayInfo: true,
                autoScroll: true,
                beforePageText: "第",// update
                afterPageText: "页  共 {0} 页",// update
                firstText: "第一页",
                prevText: "上一页",// update
                nextText: "下一页",
                lastText: "最后页",
                refreshText: "刷新",
                displayMsg: "显示 {0} - {1}条，共 {2} 条",// update
                emptyMsg: '没有数据',
                items: ['-', '每页显示', pageCombo, '条']//此处是将创建的combobox添加到工具栏中
            }],
            store: store,
            columns: [
                {
                    xtype: 'rownumberer',
                    header: '行号',
                    renderer: function (value, metadata, record, rowIndex) {
                        return (rowIndex + 1);
                    },
                    width: 60,
                    align: 'center',
                }, {
                    text: '版本ID',
                    width: 80,
                    dataIndex: 'versionId',
                    hidden: true,
                },
                {
                    text: '版本号',
                    width: 80,
                    dataIndex: 'versionNo',
                    sortable: false,
                    menuDisabled : true
                },
                {
                    text: '分析类型',
                    width: 150,
                    dataIndex: 'analyseType',
                    sortable: false,
                    menuDisabled : true
                },
                {
                    text: '分析名称',
                    flex: 10,
                    dataIndex: 'analyseName',
                    sortable: false,
                    menuDisabled : true
                },
                {
                    text: '发布时间',
                    width: 150,
                    dataIndex: 'publicTime',
                    renderer: function (value) {
                        return Ext.Date.format(new Date(value), 'Y-m-d G:i:s');
                    },
                    sortable: false,
                    menuDisabled : true
                },
                {
                    text: '权属年度',
                    dataIndex: 'needQsnd',
                    sortable: false,
                    menuDisabled : true,
                    renderer: function (value) {
                        var need = "否";
                        if (value) {
                            need = "是";
                        }
                        return need;
                    }
                },
                {
                    text: '耕地年度',
                    dataIndex: 'needGdnd',
                    sortable: false,
                    menuDisabled : true,
                    renderer: function (value) {
                        var need = "否";
                        if (value) {
                            need = "是";
                        }
                        return need;
                    }
                },
                {
                    text: '地类年度',
                    dataIndex: 'needDlnd',
                    menuDisabled : true,
                    sortable: false,
                    renderer: function (value) {
                        var need = "否";
                        if (value) {
                            need = "是";
                        }
                        return need;
                    }
                },
                {
                    text: '返回图形',
                    dataIndex: 'sffhtx',
                    sortable: false,
                    menuDisabled : true,
                    renderer: function (value) {
                        var need = "否";
                        if (value) {
                            need = "是";
                        }
                        return need;
                    }
                }, {
                    text: '操作',
                    dataIndex: 'cz',
                    width: 200,
                    sortable: false,
                    menuDisabled : true,
                    renderer: function (value, metaData, record) {
                        var id = Ext.id();
                        var buttonId = "btn_" + record.data.id;
                        metaData.tdAttr = 'data-qtip="提示信息"';
                        Ext.defer(function () {
                            Ext.widget('toolbar', {
                                renderTo: id,
                                dock: 'top',
                                style: 'margin:0',
                                ui: 'footer',
                                height: 40,
                                width: 200,
                                items: [
                                    {
                                        xtype: 'button',
                                        width: 80,
                                        height: 25,
                                        id: buttonId,
                                        text: '修改映射',
                                        handler: function () {
                                            var that = this;
                                            openMappedSumWindow(that);
                                        }
                                    }
                                ]
                            });
                        }, 50);
                        return Ext.String.format('<div id="{0}"></div>', id);
                    }
                }
            ]
            /*
            listeners:{
                'sortchange':function (ct, column, direction, eOpts) {
                    console.log("排序点击事件");
                }
            }*/
        });

        new Ext.Viewport({
            layout: 'fit',
            items: [grid]
        });

        var queryTypeStore = Ext.create('Ext.data.Store', {
            fields: ['type', 'name'],
            data: [
                {"type": "http", "name": "1"},
                {"type": "webservice", "name": "2"}
            ]
        });

        var blockTypeStore = Ext.create('Ext.data.Store', {
            fields: ['type', 'name'],
            data: [
                {"type": "GeoJson", "name": "GeoJson"},
                {"type": "WKT", "name": "WKT"}
            ]
        });

        var paramStore = Ext.create('Ext.data.Store', {
            fields: ['type', 'name'],
            data: [
                {"type": "json", "name": "1"},
                {"type": "key-value", "name": "2"}
            ]
        });

        var form = Ext.create('Ext.form.Panel', {
            border: false,
            layout: {type: 'auto', align: 'right'},
            buttonAlign: 'center',
            defaultType: 'textfield',
            bodyStyle: {
                padding: '20px'
            },
            items: [
                {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [{
                        xtype: 'textfield',
                        name: 'action',
                        hidden: true,
                        hideLabel: true
                    }, {
                        xtype: 'textfield',
                        name: 'versionId',
                        hidden: true,
                        hideLabel: true
                    }, {
                        xtype: 'textfield',
                        fieldLabel: '分析名称',
                        name: 'analyseName',
                        flex: 5,
                        allowBlank: false,
                        margin: '5 5 5 5'
                    },
                        {
                            flex: 5,
                            margin: '5 5 5 5',
                            allowBlank: false,
                            xtype: 'combobox',
                            name: 'analyseType',
                            fieldLabel: '分析类型',
                            queryModel: 'local',
                            valueField: 'type',
                            displayField: 'name',
                            store: analysisTypeStore
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: '版本号',
                            name: 'versionNo',
                            flex: 5,
                            allowBlank: false,
                            margin: '5 5 5 5',
                            vtype: 'versionCheck'
                        },
                        {
                            xtype: 'combobox',
                            name: 'queryType',
                            fieldLabel: '请求类型',
                            queryModel: 'local',
                            displayField: 'type',
                            valueField: 'name',
                            flex: 5,
                            margin: '5 5 5 5',
                            store: queryTypeStore
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: '分析描述',
                            name: 'analyseDes',
                            flex: 10,
                            allowBlank: false,
                            margin: '5 5 5 5'
                        }]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: '接口访问地址',
                            name: 'url',
                            flex: 10,
                            allowBlank: false,
                            margin: '5 5 5 5'
                        }]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: '系统识别码',
                            name: 'applicationGuid',
                            flex: 5,
                            allowBlank: false,
                            margin: '5 5 5 5'
                        },
                        {
                            xtype: 'combobox',
                            name: 'paramType',
                            fieldLabel: '参数类型',
                            queryModel: 'local',
                            displayField: 'type',
                            valueField: 'name',
                            flex: 5,
                            margin: '5 5 5 5',
                            store: paramStore
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [{
                        xtype: 'radiogroup',
                        fieldLabel: '是否返回图形',
                        margin: '5 5 5 5',
                        flex: 5,
                        vertical: true,
                        items: [
                            {boxLabel: '是', name: 'sffhtx', inputValue: '1'},
                            {boxLabel: '否', name: 'sffhtx', inputValue: '0'}
                        ]
                    },
                        {
                            xtype: 'radiogroup',
                            fieldLabel: '使用缓冲区',
                            margin: '5 5 5 5',
                            vertical: true,
                            flex: 5,
                            items: [
                                {boxLabel: '是', name: 'needBuff', inputValue: '1'},
                                {boxLabel: '否', name: 'needBuff', inputValue: '0'}
                            ]
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [{
                        xtype: 'radiogroup',
                        fieldLabel: '是否权属年度',
                        id: 'qsnd',
                        margin: '5 5 5 5',
                        flex: 5,
                        vertical: true,
                        items: [
                            {boxLabel: '是', name: 'needQsnd', inputValue: '1'},
                            {boxLabel: '否', name: 'needQsnd', inputValue: '0'}
                        ]
                    },
                        {
                            xtype: 'radiogroup',
                            id: 'gdnd',
                            fieldLabel: '是否耕地年度',
                            margin: '5 5 5 5',
                            vertical: true,
                            flex: 5,
                            items: [
                                {boxLabel: '是', name: 'needGdnd', inputValue: '1'},
                                {boxLabel: '否', name: 'needGdnd', inputValue: '0'}
                            ]
                        }
                    ]
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [{
                        xtype: 'radiogroup',
                        fieldLabel: '是否地类年度',
                        margin: '5 5 5 5',
                        width: '49%',
                        vertical: true,
                        items: [
                            {boxLabel: '是', name: 'needDlnd', inputValue: '1'},
                            {boxLabel: '否', name: 'needDlnd', inputValue: '0'}
                        ]
                    },
                        {
                        xtype: 'radiogroup',
                        fieldLabel: '使用吉威平差',
                        margin: '5 5 5 5',
                        width: '49%',
                        vertical: true,
                        items: [
                            {boxLabel: '是', name: 'needGeoWayAdjust', inputValue: '1'},
                            {boxLabel: '否', name: 'needGeoWayAdjust', inputValue: '0'}
                        ]
                    }]
                },
                {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'radiogroup',
                            fieldLabel: '已批红线校验',
                            margin: '5 5 5 5',
                            width: '49%',
                            vertical: true,
                            items: [
                                {boxLabel: '是', name: 'needYphx', inputValue: '1'},
                                {boxLabel: '否', name: 'needYphx', inputValue: '0'}
                            ]
                        },{
                            xtype: 'textfield',
                            fieldLabel: '限制面积',
                            name: 'maxArea',
                            flex: 5,
                            margin: '5 5 5 5'
                        }
                    ]
                },

                {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [ {
                            xtype: 'textfield',
                            fieldLabel: '请求超时时间',
                            name: 'timeoutTime',
                            flex: 5,
                            margin: '5 5 5 5'
                        }
                    ]
                },
                {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [{
                        xtype: 'combobox',
                        name: 'blockType',
                        fieldLabel: 'Block格式',
                        queryModel: 'local',
                        displayField: 'type',
                        valueField: 'name',
                        allowBlank: false,
                        flex: 5,
                        margin: '5 5 5 5',
                        store: blockTypeStore
                    }]
                },
                {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [{
                        xtype: 'textarea',
                        name:'bz',
                        fieldLabel: '备注',
                        margin: '5 5 5 5',
                        flex: 10
                    }]
                }
            ]
        });

        var profileWindow = Ext.create('Ext.Window', {
            title: '分析版本配置',
            width: 600,
            height: 650,
            resizable: false,
            modal: true,
            items: [form],
            maximizable: true,
            minimizable: true,
            closeAction: 'hide',//设置点击关闭按钮为隐藏,不设置，window不能重复利用
            buttons: [{
                xtype: 'button', text: '确定', handler: function () {
                    saveAnalyseVersion();
                }
            }, {
                xtype: 'button', text: '取消', handler: function () {
                    profileWindow.hide();
                }
            }]
        });


        /***
         * 获取选中的数据,至提供单选模式
         */
        function getSelectionRecord() {
            var records = grid.selModel.getSelection();
            if (records.length != 1) {
                Ext.MessageBox.alert('提示', '只能选中一条数据进行处理!');
            }
            return records[0];
        }


        /***
         * 新增分析版本信息
         */
        function deleteRecord() {
            var record = getSelectionRecord();
            console.log(record);
            Ext.Msg.show({
                title: '提示',
                message: '是否确认删除？',
                buttons: Ext.Msg.YESNO,
                icon: Ext.Msg.QUESTION,
                fn: function (btn) {
                    if (btn === 'yes') {
                        Ext.Ajax.request({
                            method: 'POST',
                            url: GS.global.ctxPath + '/analyse/deleteAnalyseVersion',
                            params: {
                                'versionId': record.get("versionId")
                            },
                            success: function (response, config) {
                                Ext.Msg.alert('提示', '删除成功!');
                                grid.store.reload();//重新加载数据
                            },
                            failure: function () {
                                Ext.Msg.alert('提示', '删除失败!');
                            }
                        });
                    }

                }
            })


        }

        /***
         * 打开分配配置页面
         */
        function doAnalyseProfile(action) {
            /**清空表单数据**/
            form.getForm().reset();
            /**设置表单action的值*/
            form.getForm().findField('action').setValue(action);
            var title = "";
            if (action == 'add') {
                setInitParamNeed(['sffhtx', 'needBuff', 'needQsnd', 'needGdnd', 'needDlnd','needGeoWayAdjust']);
                title = '新增分析配置';
            } else if (action == 'update') {
                title = '修改分析配置';
                /**加载选中数据*/
                var record = getSelectionRecord();
                /**加载数据*/
                form.getForm().loadRecord(record);

            } else if (action == 'check') {
                title = '查看分析配置';
            }
            /**设置标题**/
            profileWindow.setTitle(title);
            profileWindow.show();
        }

        /**
         * 保存分析版本配置信息
         */
        function saveAnalyseVersion() {
            var form_ = form.getForm();
            var action = form_.findField('action').getValue();
            console.log(action);
            if (form_.isValid()) {
                var url = GS.global.ctxPath + "/analyse/saveAnalyseVersion";
                var msg = '添加成功!';
                if (action == 'update') {
                    url = GS.global.ctxPath + "/analyse/updateAnalyseVersion";
                    msg = '更新成功!';
                }
                form_.submit({
                    method: 'POST',
                    url: url,
                    waitMsg: '请稍等,正在执行',
                    params: form_.getValues(),
                    success: function (form, action) {
                        /*关闭窗口**/
                        profileWindow.hide();
                        grid.store.reload();
                        Ext.MessageBox.alert('提示', msg);
                    },
                    failure: function (form, action) {
                        Ext.MessageBox.alert('提示', "操作失败");
                    }

                })
            }
        }


        /**由于使用给groupRadio加checked的方式渲染会导致出现2个值，所以使用该方法进行设置默认***/
        function setInitParamNeed(initParamList) {
            initParamList.forEach(
                element => {
                    form.getForm().findField(element).setValue(initNeededParam.INIT_PARAM_ISUNNEED);
                }
            );
        }

        /**打开分析映射配置窗口并渲染值**/
        function openMappedSumWindow(that) {
            var record_id = that.id.split("_")[1];
            var dataArray = Ext.getCmp("versionGrid").store.data.items;
            var analyseTypeChoose = "";
            for (var i = 0; i < dataArray.length; i++) {
                if (dataArray[i].id === parseInt(record_id)) {
                    analyseTypeChoose = dataArray[i].data.analyseType;
                }
            }
            // var analyseTypeChoose = dataArray.forEach(element => {
            //     if(element.id===parseInt(record_id)){
            //         return element.data.analyseType;}
            // });
            Ext.getCmp("mapped_analyse_type").setValue(analyseTypeChoose);
            mappedSumWindow.show();
        }

        function doMappedAnalyseProfile() {
            var mappedAnalyseType = Ext.getCmp("mapped_analyse_type").getValue();
            var formMapped_ = formMapped.getForm();
            var url = GS.global.ctxPath + "/analyseMapped/insertAnalyseMapped";
            formMapped_.findField('modifiedTime').setValue(new Date());
            if (formMapped_.isValid()) {
                formMapped_.submit({
                    method: 'POST',
                    url: url,
                    waitMsg: '请稍等,正在执行',
                    params: formMapped_.getValues(),
                    success: function () {
                        formMapped_.reset();
                        Ext.getCmp("mapped_analyse_type").setValue(mappedAnalyseType);
                        gridMapped.store.reload();
                    },
                    failure: function () {
                        Ext.MessageBox.alert('提示', "操作失败");
                    }

                })
            }
        }


        /***
         * 获取选中的数据,至提供单选模式
         */
        function getSelectionRecordMapped() {
            var records = gridMapped.selModel.getSelection();
            if (records.length != 1) {
                Ext.MessageBox.alert('提示', '只能选中一条数据进行处理!');
            }
            return records[0];
        }

        /**
         * 删除mapped信息
         */
        function deleteMappedRecordMapped() {
            var record = getSelectionRecordMapped();
            if (!record) {
                Ext.MessageBox.alert('提示', '只能选中一条数据进行处理!');
                return;
            }
            Ext.Msg.show({
                title: '提示',
                message: '是否确认删除？',
                buttons: Ext.Msg.YESNO,
                icon: Ext.Msg.QUESTION,
                fn: function (btn) {
                    if (btn === 'yes') {
                        Ext.Ajax.request({
                            method: 'POST',
                            url: GS.global.ctxPath + '/analyseMapped/deleteAnalyseMapped',
                            params: {
                                'mappingId': record.get("mappingId")
                            },
                            success: function (response, config) {
                                Ext.Msg.alert('提示', '删除成功!');
                                gridMapped.store.reload();//重新加载数据
                            },
                            failure: function () {
                                Ext.Msg.alert('提示', '删除失败!');
                            }
                        });
                    }

                }
            })


        }

    })


</script>
</body>
</html>